import 'package:get/get.dart';

class Routes {
  static Future<T> push<T>(String routeName, {params}) async {
    Map<String, dynamic> map = Map();
    map.putIfAbsent("obj", () => params);
    return await Get.toNamed(routeName, arguments: map);
  }

  static Future<T> replacePush<T>(String routeName, {params}) async {
    Map<String, dynamic> map = Map();
    map.putIfAbsent("obj", () => params);
    return await Get.offNamed(routeName, arguments: map);
  }

  static Future<T> off<T>(String routeName, {params}) async {
    Map<String, dynamic> map = Map();
    map.putIfAbsent("obj", () => params);
    return await Get.off(routeName, arguments: map);
  }

  static Future<T> replaceAllPush<T>(String routeName, {params}) async {
    Map<String, dynamic> map = Map();
    map.putIfAbsent("obj", () => params);
    return await Get.offAllNamed(routeName, arguments: map);
  }

  static pop<T>({result}) {
    return Get.back(result: result);
  }

  static getParams<T>() {
    return Get.arguments == null ? null : Get.arguments['obj'];
  }
}
